package com.danco.training.zaneuskaya.controller.order;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.danco.training.zaneuskaya.api.OrderService;
import com.danco.training.zaneuskaya.controller.GenericController;
import com.danco.training.zaneuskaya.service.impl.OrderServiceImpl;

public class OrderListController extends GenericController{

	/**
	 * 
	 */
	private static final long serialVersionUID = 4419056085765212264L;
	
	private OrderService orderService;

	public OrderListController() {
		super();
		orderService = OrderServiceImpl.getOrderStorageServiceInstance();
	}
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {

		
		req.setAttribute("orders", orderService.getOrdersSortedByOrderDate());
		req.getRequestDispatcher("/WEB-INF/views/order/list.jsp").forward(req, resp);

	}
	
	

}
